<template>
  <div>
    <a-card :bordered='false'>
      <f-search-form :more='true' @searchHandler='searchHandler'>
        <f-search-form-item label='单号' name='orderNo' style="width: 250px"/>
        <f-search-form-item label="部门" ref="dept" name="deptId" slot="advanced" type="select"  :data="api.dept.list"  valueKey="deptId" label-key="deptName" style="width: 220px"/>
        <f-search-form-item label="发货开始日期" type="date" name="beginDate" v-if="current=='form3'" :visible="current=='form3'" />
        <f-search-form-item label="发货结束日期" type="date" name="endDate" v-if="current=='form3'" :visible="current=='form3'" />
        <f-search-form-item label="供方资信" type="select" slot="advanced" v-if="current=='form3'" :visible="current=='form3'"  name="supplierBondType" :data="api.busOrder.supplierBondType" />
        <f-search-form-item label="购方资信" type="select" slot="advanced" v-if="current=='form3'" :visible="current=='form3'"  name="customBondType" :data="api.busOrder.customBondType" />
        <f-search-form-item label="购货方" name="customName" slot="advanced" v-if="current=='form3'" :visible="current=='form3'"  style="width: 250px"/>
        <f-search-form-item label="供货方" name="supplierName" slot="advanced" v-if="current=='form3'" :visible="current=='form3'"  style="width: 250px"/>
      </f-search-form>
      <a-tabs @tabClick='tabClick' :defaultActiveKey='current' v-model='current'>
        <a-tab-pane tab='我的待办' key='form1'>
          <todo-no ref='form1' v-if="current=='form1'"></todo-no>
        </a-tab-pane>
        <a-tab-pane tab='办理中' key='form2'>
          <todo-yes ref='form2' v-if="current=='form2'"></todo-yes>
        </a-tab-pane>
        <a-tab-pane tab='已审批' key='form3'>
          <order-end ref='form3' v-if="current=='form3'"></order-end>
        </a-tab-pane>
      </a-tabs>
    </a-card>
  </div>
</template>
<script>

import api from './js/api'
import TodoNo from './tab1'
import TodoYes from './tab2'
import OrderEnd from '@/views/module/business/order/index/order'

export default {
  name: 'Tabs',
  components: { OrderEnd, TodoNo, TodoYes },
  data() {
    let me = this
    return {
      api: Object.assign(api, this.api),
      //列表初始化查询参数
      queryParam: {},
      current: 'form1',
      forms: [
        'form1',
        'form2'
      ]
    }
  },
  created() {
  },
  methods: {
    tabClick(name) {
      this.current = name
      this.$nextTick(() => {
        this.searchHandler(name)
      })
    },
    searchHandler(searchParams) {
      if (this.current == 'form1') {
        this.$refs[this.current].searchHandler(searchParams)
      } else {
        this.$refs[this.current].searchHandler(searchParams)
      }

    }
  }
}
</script>
